package com.liy.framework.web.rs.filter;

import com.liy.framework.common.extvo.ResultVO;
import java.io.IOException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RequestFilter implements ContainerRequestFilter {
    protected static Logger log = LoggerFactory.getLogger(RequestFilter.class);

    public RequestFilter() {}

    public void filter(ContainerRequestContext requestContext) throws IOException {
        log.info("jaxrs request filter：" + requestContext.getUriInfo().getAbsolutePath().toString());
    }

    private void stopAccess(ContainerRequestContext requestContext, String code, String message) {
        requestContext.abortWith(Response.status(Status.UNAUTHORIZED).entity(new ResultVO(false, message, code)).build());
    }
}
